
let obj1={name:"zs",hoby:{foods:["返根豪","法国海军"]}};
function copy(target){
    let temp;
    if(target instanceof Object){
        if(target instanceof Array){
           temp=[] 
        }else{
            temp={}
        }
        //遍历target
        for(var key in target){
            let val=target[key]
            if(typeof val==Object){
                temp[key]=copy(val)
            }else{
                temp[key]=target[key]
            }
        }
    }else{
        temp=target;
    }
    return temp;
}
let obj2=copy(obj1);
console.log(obj2)
